<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			.smallDiv {
				width: 30px;
				height: 30px;
				display: inline-block;
				/* 行内块 */
			}
		</style>
	</head>
	<body>

		<script type="text/javascript">
			// const 常量
			const N = 20;
			for (var i = 0; i < N; i++) {
				document.write("<div>");
				for (var j = 0; j < N; j++) {
					// 随机红绿蓝三原色
					var r = Math.floor(Math.random() * 256);
					var g = Math.floor(Math.random() * 256);
					var b = Math.floor(Math.random() * 256);
					// 生成十六进制颜色值 如#ff00ff
					var color = "#" + r.toString(16) + g.toString(16) + b.toString(16);
					document.write("<div class='smallDiv' style='background-color: " + color + ";'></div>");
				}
				document.write("</div>");
			}
		</script>
	</body>
</html>
